package com.example.figurehecheng.controller.merchant;


import com.example.figurehecheng.common.result.PageResult;
import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.SubscribePageDTO;
import com.example.figurehecheng.domain.entity.Subscribe;
import com.example.figurehecheng.service.ISubscribeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
@RestController("merchantSubscribeController")
@RequestMapping("/merchant/subscribe")
@CrossOrigin
@Api(tags = "预约管理")
@RequiredArgsConstructor
@Slf4j
public class SubscribeController {

    private final ISubscribeService subscribeService;

    /**
     * 查询预约
     * @param subscribePageDTO
     * @return
     */
    @GetMapping("/selectPageSubscribe")
    @ApiOperation("查询预约")
    public Result<PageResult> selectPageSubscribe(SubscribePageDTO subscribePageDTO){
        log.info("查询预约: {}", subscribePageDTO);
        PageResult pageResult = subscribeService.selectPageSubscribe(subscribePageDTO);
        return Result.success(pageResult);
    }


    /**
     * 修改预约状态
     * @param id
     * @param state
     * @return
     */
    @PutMapping("/updateState/{id}/{state}")
    @ApiOperation("修改预约状态")
    public Result updateState(@PathVariable Integer id, @PathVariable Integer state){
        log.info("修改预约状态: {}, {}", id, state);
        subscribeService.updateState(id, state);
        return Result.success();
    }


}
